﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Project.Engine.Control;
using Project.Engine.Utilities;
using Project.Module.Model;
using Project.Module.DAO.BL;

namespace Project.Module.View
{
    public class ChiTietCongThucView : DocumentInfo
    {
        public ProductModel detailProduct = null;
        public List<FeedBackModel> comment = null;

        private EventBL eventBl = new EventBL();
        private FeedBackBL feedbackBl = new FeedBackBL();
        private ProductBL productBl = new ProductBL();
        private int congThucId = DefineUtil.congThucId;

        public ChiTietCongThucView(int nodeid, string nodealias)
        {
            Init(nodeid);
        }

        private void Init(int nodeid)
        {
            GetDetailEvent(nodeid);
            GetComment(nodeid);
        }

        private void GetDetailEvent(int productId)
        {
            this.detailProduct = productBl.GetDetailProduct(productId);
            if (this.detailProduct != null)
            {
                this.detailProduct.ImagePath = eventBl.GetImagePathById(this.detailProduct.ImageID);
                this.detailProduct.title = StringUtil.ShortContent(this.detailProduct.Description, 5);
            }
        }

        protected void GetComment(int productId)
        {
            this.comment = feedbackBl.GetCommentProduct(productId, congThucId);
        }
    }
}
